package blog.com.mw.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HtmlConvert {
	public static String HtmlConvertContent(String str) {
		String regex="<.*?>";
		System.out.println("变化前"+str);
	    Pattern p = Pattern.compile(regex);
	    Matcher m = p.matcher(str); 
	    str = m.replaceAll("");
	    System.out.println("变化后"+str);
		return str;
	}
	
	public static List<String> getPirtureByContent(String str) {
		String format = "bmp,png,tif,gif,pcx,tga,exif,jpeg,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp";
		String[] strs = format.split(",");
		List<String> imgs = new ArrayList<>();
		StringBuilder regex= new StringBuilder("http(s?):.*?\\.(jpg");
		for(String sr : strs) {
			regex.append("|");
			regex.append(sr);
		}
		regex.append(")");
		
		System.out.println("变化前"+str);
	    Pattern p = Pattern.compile(regex.toString());
	    Matcher m = p.matcher(str); 
        while (m.find()) {
        	System.out.println("匹配结果:"+m.group());
        	imgs.add(m.group());
        }
	    System.out.println("匹配后数组:"+imgs.toString());
		return imgs;
	}

	
	/*
	 * public static void main(String[] args) { String str =""; List<String> res =
	 * getPirtureByContent(str); System.out.println(res); }
	 */

}
